home *** CD-ROM | disk | FTP | other *** search
- FUNCTION which_turbo: INTEGER;
-
- {The upper left hand corner of the window is stored with the upper left
- hand corner of the screen as (0,0) in:
- Turbo, IBM-PC Version 2.00B - Dseg:$156, Dseg:$157
- Turbo-87, IBM-PC Version 2.00B - Dseg:$143, Dseg:$144
- Turbo, IBM-PC Version 3.01A - Dseg:$4, Dseg:$5
- Turbo-87, IBM-PC Version 3.01A - Dseg:$4, Dseg:$5
- Turbobcd, IBM-PC Version 3.01A - Dseg:$4, Dseg:$5
-
- The lower right hand corner of the window is stored with the upper left
- hand corner of the screen as (1,10) in
- Cseg:$16A, Cseg:$16B
- in all three cases.
-
- The function tests which Turbo is being used by setting a window with a
- different upper left hand corner, then seeing which one matches. It
- returns 3 for any IBM-PC Version 3.01A, 2 for Turbo, IBM-PC Version
- 2.00B , 287 for Turbo-87, IBM-PC Version 2.00B, and 0 for other locations
- of the upper left hand corner of the window. If the function returns 0,
- it can not restore the window, so it is up to the programmer to do it.
-
- I found these locations by snooping in compiled files. They may not be
- correct for other sub-versions of Turbo. Almost surely, they will not be
- correct for a new major revision. As a result, the function is not
- robust.
-
- It would be helpful if Borland were to give official ways to find the
- window coordinates and to find the version.
-
- Lew Paper
- 12/9/85}
-
- VAR
- x1_v2, y1_v2, {Turbo Version 2 upper left hand coordinates}
- x1_v287, y1_v287, {Turbo-87 Version 2 upper left hand
- coordinates}
- x1_v3, y1_v3, {Version 3 upper left hand coordinates}
- x2, y2, {Lower right hand coordinates}
- test_ulx, test_uly : INTEGER;
-
- BEGIN {FUNCTION which_turbo}
-
- {Save old values}
-
- x1_v2 := MEM[DSEG:$156] + 1;
- y1_v2 := MEM[DSEG:$157] + 1;
-
- x1_v287 := MEM[DSEG:$143] + 1;
- y1_v287 := MEM[DSEG:$144] + 1;
-
- x1_v3 := MEM[DSEG:$4] + 1;
- y1_v3 := MEM[DSEG:$5] + 1;
-
- x2 := MEM[CSEG:$16A];
- y2 := MEM[CSEG:$16B];
-
- {Bela Lubkin at Borland developed this method of finding a value of
- test_ulx which equals neither x1_v2 nor x1_v3.}
- test_ulx := 1; {Arbitrary, so long as it is at least 3 less than maximum}
- IF (x1_v2 = test_ulx) OR (x1_v287 = test_ulx) OR (x1_v3 = test_ulx)
- THEN
- BEGIN
- test_ulx := 2;
- IF (x1_v2 = test_ulx) OR (x1_v287 = test_ulx) OR (x1_v3 = test_ulx)
- THEN
- BEGIN
- test_ulx := 3;
- IF (x1_v2 = test_ulx) OR (x1_v287 = test_ulx)
- OR (x1_v3 = test_ulx) {All three are <= 3}
- THEN
- test_ulx := 4;
- END; {Middle IF (x1_v2 = test_ulx) OR (x1_v287 = test_ulx) OR
- (x1_v3 = test_ulx)}
- END; {Outer IF (x1_v2 = test_ulx) OR (x1_v287 = test_ulx) OR
- (x1_v3 = test_ulx)}
- test_uly := 1;
-
- WINDOW(test_ulx, test_uly, x2, y2);
-
- IF MEM[DSEG:$4] = test_ulx - 1
- THEN
- which_turbo := 3
- ELSE IF MEM[DSEG:$156] = test_ulx - 1
- THEN
- which_turbo := 2
- ELSE IF MEM[DSEG:$143] = test_ulx - 1
- THEN
- which_turbo := 287
- ELSE
- which_turbo := 0;
-
- {Restore the original window}
- IF MEM[DSEG:$4] = test_ulx - 1
- THEN
- WINDOW(x1_v3, y1_v3, x2, y2)
- ELSE IF MEM[DSEG:$156] = test_ulx - 1
- THEN
- WINDOW(x1_v2, y1_v2, x2, y2)
- ELSE IF MEM[DSEG:$143] = test_ulx - 1
- THEN
- WINDOW(x1_v287, y1_v287, x2, y2);
-
- END; {FUNCTION which_turbo}
-
- (*
- VAR
- version: INTEGER;
-
- BEGIN {Test program}
- CLRSCR;
- WRITE('This is line 1 of the original window');
- version := which_turbo;
- IF version = 0
- THEN
- WINDOW(1, 1, 80, 25);
- GOTOXY(1, 2);
- WRITE('This is line 2 of the original window');
- GOTOXY(1, 4);
- IF version > 0
- THEN
- WRITE('The program was compiled by Turbo, Version ', version)
- ELSE
- WRITE('which_turbo cannot determine the version of Turbo which ',
- 'compiled this program');
- END. {Test program}
- *)